﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DTO
{
    [Serializable]
    public class ResultList
    {
        public bool IsSuccess { get { return Code == 0; } }
        public int Code { get; set; } = 0;
        public string Msg { get; set; }
        public int Count { get; set; } = 0;
        public object Data { get; set; }

        #region 返回成功json
        public static ResultList Success(string msg = "", int count = 0, object data = null)
        {
            return new ResultList
            {
                Code = 0,
                Msg = msg,
                Count = count,
                Data = data
            };
        }
        #endregion

        #region 错误json
        public static ResultList Failed(int code, string msg)
        {
            return new ResultList
            {
                Code = code,
                Msg = msg
            };
        }
        #endregion
    }
}
